; Music of Tom & Jerry (1989) (Magic Bytes)
; Ripped by Megachur the 17/03/2009

	write "TOM&JERR.BIN"

music_date_rip	equ &1139
music_adr	equ &0902+&3f00
first_theme	equ 7
last_theme	equ 7	; 7 -> 7

	read "music_header_v1_0.asm"

.l0902
	push af
	push bc
	push de
	push hl
;call l094b modifed by Megachur
	defs 3,0
	pop hl
	pop de
	pop bc
	pop af
	ld (l0af7),a
	ld (l0ae3),bc
	ld (l0ae1),de
	ld (l0adf),hl
	ld a,#03
	ld (l0ade),a
	ld a,#0d
	ld (l0ae5),a
	inc a
	ld (l0ae6),a
	inc a
	ld (l0ae7),a
	call l0965
	call l0957
	ld c,#38
	ld a,#07
	call l0ac0
	di
;ld hl,l0897
;ld (#0039),hl	modified by Megachur
	defs 6,0
	xor a
	ld (l0aeb),a
	inc a
	ld (l0af8),a
	ei
	ret
.l094b
	di
	xor a
	ld (l0af8),a
	ld hl,(l0af9)
	ld (#0039),hl
	ei
.l0957
	ld d,#03
.l0959
	ld a,#07
	add d
	ld c,#00
	call l0ac0
	dec d
	jr nz,l0959
	ret
.l0965
	ld hl,(l0adf)
	ld (l0aec),hl
	ld hl,(l0ae1)
	ld (l0aee),hl
	ld hl,(l0ae3)
	ld (l0af0),hl
	ld a,#01
	ld (l0af2),a
	ld (l0af3),a
	ld (l0af4),a
	ret
;
.play_music
;
	ld hl,l0aeb
	inc (hl)
	ld a,(l0af7)
	cp (hl)
	ret nz
	ld (hl),#00
	ld hl,l0af2
	ld bc,l0adf
	ld de,l0aec
	xor a
	call l09ac
	ld a,#01
	inc hl
	inc bc
	inc bc
	inc de
	inc de
	call l09ac
	ld a,#02
	inc hl
	inc bc
	inc bc
	inc de
	inc de
.l09ac
	dec (hl)
	ret nz
	push hl
	push bc
	push de
	push af
	ld (l0af5),hl
	ld a,(de)
	ld l,a
	inc de
	ld a,(de)
	ld h,a
	inc hl
	inc hl
	ld a,h
	ld (de),a
	dec de
	ld a,l
	ld (de),a
	ld a,(hl)
	and a
	jr nz,l09df
	ld a,(bc)
	ld (de),a
	inc de
	inc bc
	ld a,(bc)
	ld (de),a
	ld a,#01
	ld hl,(l0af5)
	ld (hl),a
.l09d1
	pop af
	push af
	add #08
	ld c,#00
	call l0ac0
.l09da
	pop af
	pop de
	pop bc
	pop hl
	ret
.l09df
	bit 7,a
	jr z,l09ec
	res 7,a
	ld bc,(l0af5)
	ld (bc),a
	jr l09d1
.l09ec
	ld bc,(l0af5)
	ld (bc),a
	inc hl
	push hl
	ld a,(hl)
	and #f0
	srl a
	ld e,a
	sla a
	add e
	ld e,a
	ld d,#00
	ld hl,l0a30
	add hl,de
	ld b,h
	ld c,l
	pop hl
	ld a,(hl)
	and #0f
	ld e,a
	sla e
	ld h,b
	ld l,c
	add hl,de
	pop af
	push af
	sla a
	push af
	ld c,(hl)
	call l0ac0
	pop af
	inc a
	inc hl
	ld c,(hl)
	call l0ac0
	pop af
	push af
	ld hl,l0ae5
	ld e,a
	ld d,#00
	add hl,de
	add #08
	ld c,(hl)
	call l0ac0
	jr l09da
.l0a30
	dw #0777,#070c,#06a7,#0647
	dw #05ed,#0598,#0547,#04fc
	dw #04d4,#0470,#0431,#03f4
	dw #03dc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#002d,#002a,#0028
	dw #0026,#0024,#0022,#0020
.l0ac0
	ld b,#f4
	out (c),a
	ld b,#f6
	in a,(c)
	or #c0
	out (c),a
	and #3f
	out (c),a
	ld b,#f4
	out (c),c
	ld b,#f6
	ld c,a
	or #80
	out (c),a
	out (c),c
	ret
.l0ae5 equ $ + 7
.l0ae3 equ $ + 5
.l0ae1 equ $ + 3
.l0adf equ $ + 1
.l0ade
	db #00,#00,#00,#00,#00,#00,#00,#00
.l0aec equ $ + 6
.l0aeb equ $ + 5
.l0ae7 equ $ + 1
.l0ae6
	db #00,#00,#00,#00,#00,#00,#00,#00
.l0af5 equ $ + 7
.l0af4 equ $ + 6
.l0af3 equ $ + 5
.l0af2 equ $ + 4
.l0af0 equ $ + 2
.l0aee
	db #00,#00,#00,#00,#00,#00,#00,#00
.l0af8 equ $ + 2
.l0af7 equ $ + 1
	db #00,#00,#00
.l0af9
	dw #b941
	ld (l0bc0),hl
	ld (l0bc6),bc
	push hl
	push hl
	ld d,(hl)
	inc hl
	ld e,(hl)
	ld hl,#0004
	add hl,de
	pop de
	add hl,de
	ld (l0bc2),hl
	pop hl
	inc hl
	inc hl
	ld b,(hl)
	inc hl
	ld c,(hl)
	ld hl,(l0bc6)
	add hl,bc
	ld (l0bc4),hl
	ld hl,(l0bc2)
	dec hl
	ld (l0bc2),hl
	ld a,(hl)
.l0b25
	srl a
	call z,l0b9b
	jr c,l0b59
	ld b,#08
	ld c,#02
	srl a
	call z,l0b9b
	jr c,l0b7c
	ld b,#03
	call l0bb1
	inc de
.l0b3d
	ld b,#08
.l0b3f
	srl a
	call z,l0b9b
	rl c
	djnz l0b3f
	ld hl,(l0bc4)
	dec hl
	ld (l0bc4),hl
	ld (hl),c
	dec de
	ld l,a
	ld a,d
	or e
	ld a,l
	jr nz,l0b3d
	jr l0b8e
.l0b59
	ld b,#02
	call l0bb1
	ld d,a
	ld a,e
	cp #02
	jr c,l0ba8
	ld a,d
	jr z,l0b73
	ld b,#08
	call l0bb1
	ld hl,#0009
	add hl,de
	ex de,hl
	jr l0b3d
.l0b73
	ld b,#08
	call l0bb1
	inc de
	ld c,e
	ld b,#0c
.l0b7c
	call l0bb1
.l0b7f
	ld hl,(l0bc4)
	dec hl
	ld (l0bc4),hl
	push hl
	add hl,de
	ld b,(hl)
	pop hl
	ld (hl),b
	dec c
	jr nz,l0b7f
.l0b8e
	ld hl,(l0bc6)
	ld de,(l0bc4)
	cp a
	sbc hl,de
	ret z
	jr l0b25
.l0b9b
	push hl
	ld hl,(l0bc2)
	dec hl
	ld (l0bc2),hl
	ld a,(hl)
	pop hl
	scf
	rra
	ret
.l0ba8
	add #09
	ld b,a
	sub #06
	ld c,a
	ld a,d
	jr l0b7c
.l0bb1
	ld de,#0000
.l0bb4
	srl a
	call z,l0b9b
	rl e
	rl d
	djnz l0bb4
	ret
.l0bc6 equ $ + 6
.l0bc4 equ $ + 4
.l0bc2 equ $ + 2
.l0bc0
	db #53,#25,#57,#25,#00,#c0,#00,#c0
	db #00,#08,#02,#0b,#01,#01,#0e,#19
	db #18,#0f,#17,#03,#06,#0e,#03,#1a
	db #01,#0d,#00,#0e,#03,#06,#0a,#0f
	db #10,#18,#1a,#04,#09,#0a,#12,#13

;	org &4ae8

.l4ae8
	db #04,#04,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#02,#29
	db #02,#29,#02,#35,#02,#35,#02,#2b
	db #02,#2b,#02,#37,#02,#37,#02,#30
	db #02,#37,#02,#40,#02,#37,#02,#44
	db #02,#42,#02,#40,#02,#3b,#02,#25
	db #02,#25,#02,#35,#02,#35,#02,#27
	db #02,#27,#02,#37,#02,#37,#02,#30
	db #02,#37,#02,#40,#02,#37,#02,#40
	db #02,#37,#04,#30,#02,#29,#02,#29
	db #02,#35,#02,#35,#02,#2b,#02,#2b
	db #02,#37,#02,#37,#02,#30,#02,#37
	db #02,#40,#02,#37,#02,#44,#02,#42
	db #02,#40,#02,#3b,#02,#25,#02,#25
	db #02,#35,#02,#35,#02,#27,#02,#27
	db #02,#37,#02,#37,#02,#30,#02,#37
	db #02,#40,#02,#37,#02,#40,#02,#37
	db #04,#30,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#02,#25,#02,#29,#02,#24
	db #02,#29,#02,#22,#02,#29,#02,#20
	db #02,#29,#02,#25,#02,#29,#02,#30
	db #02,#29,#02,#34,#02,#32,#02,#30
	db #02,#2b,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#04,#30,#04,#2b,#04,#29
	db #04,#27,#04,#25,#04,#27,#06,#30
	db #02,#40,#02,#29,#02,#29,#02,#35
	db #02,#35,#02,#2b,#02,#2b,#02,#37
	db #02,#37,#02,#30,#02,#37,#02,#40
	db #02,#37,#02,#44,#02,#42,#02,#40
	db #02,#3b,#02,#25,#02,#25,#02,#35
	db #02,#35,#02,#27,#02,#27,#02,#37
	db #02,#37,#02,#30,#02,#37,#02,#40
	db #02,#37,#02,#40,#02,#37,#04,#30
	db #04,#30,#04,#2b,#04,#29,#04,#27
	db #04,#25,#04,#27,#06,#30,#02,#40
	db #04,#30,#04,#2b,#04,#29,#04,#27
	db #04,#25,#04,#27,#06,#30,#02,#40
	db #04,#30,#04,#2b,#04,#29,#04,#27
	db #04,#25,#04,#27,#06,#30,#02,#40
	db #04,#30,#04,#2b,#04,#29,#04,#27
	db #04,#25,#04,#27,#06,#30,#02,#40
	db #02,#29,#02,#29,#02,#35,#02,#35
	db #02,#2b,#02,#2b,#02,#37,#02,#37
	db #02,#30,#02,#37,#02,#40,#02,#37
	db #02,#44,#02,#42,#02,#40,#02,#3b
	db #02,#25,#02,#25,#02,#35,#02,#35
	db #02,#27,#02,#27,#02,#37,#02,#37
	db #02,#30,#02,#37,#02,#40,#02,#37
	db #02,#40,#02,#37,#04,#30,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
	db #04,#27,#06,#30,#02,#40,#04,#30
	db #04,#2b,#04,#29,#04,#27,#04,#25
.l4d13 equ $ + 7
	db #04,#27,#08,#30,#90,#00,#00,#00
	db #00,#02,#44,#02,#44,#02,#42,#02
	db #42,#02,#40,#02,#40,#02,#3b,#02
	db #3b,#02,#39,#02,#40,#02,#3b,#02
	db #37,#02,#40,#02,#37,#04,#30,#02
	db #44,#02,#44,#02,#42,#02,#42,#02
	db #40,#02,#40,#02,#3b,#02,#3b,#02
	db #39,#02,#40,#02,#3b,#02,#37,#02
	db #40,#02,#37,#04,#30,#02,#44,#02
	db #44,#02,#42,#02,#42,#02,#40,#02
	db #40,#02,#3b,#02,#3b,#02,#39,#02
	db #40,#02,#3b,#02,#37,#02,#40,#02
	db #37,#04,#30,#02,#44,#02,#44,#02
	db #42,#02,#42,#02,#40,#02,#40,#02
	db #3b,#02,#3b,#02,#39,#02,#40,#02
	db #3b,#02,#37,#02,#40,#02,#37,#04
	db #30,#02,#44,#02,#44,#02,#42,#02
	db #42,#02,#40,#02,#40,#02,#3b,#02
	db #3b,#02,#39,#02,#40,#02,#3b,#02
	db #37,#02,#40,#02,#37,#04,#30,#06
	db #49,#02,#49,#04,#4b,#02,#47,#02
	db #4b,#04,#50,#04,#52,#02,#54,#02
	db #52,#04,#50,#06,#57,#02,#55,#04
	db #54,#04,#55,#10,#54,#06,#49,#02
	db #49,#04,#4b,#02,#47,#02,#4b,#04
	db #50,#04,#52,#02,#54,#02,#52,#04
	db #50,#06,#57,#02,#55,#04,#54,#04
	db #55,#10,#54,#02,#44,#02,#44,#02
	db #42,#02,#42,#02,#40,#02,#40,#02
	db #3b,#02,#3b,#02,#39,#02,#40,#02
	db #3b,#02,#37,#02,#40,#02,#37,#04
	db #30,#02,#44,#02,#44,#02,#42,#02
	db #42,#02,#40,#02,#40,#02,#3b,#02
	db #3b,#02,#39,#02,#40,#02,#3b,#02
	db #37,#02,#40,#02,#37,#04,#30,#02
	db #39,#01,#49,#01,#59,#02,#37,#01
	db #47,#01,#57,#02,#35,#01,#45,#01
	db #55,#02,#34,#01,#44,#01,#54,#02
	db #30,#02,#40,#02,#32,#02,#42,#02
	db #27,#01,#37,#01,#47,#02,#27,#02
	db #37,#02,#44,#02,#44,#02,#42,#02
	db #42,#02,#40,#02,#40,#02,#3b,#02
	db #3b,#02,#39,#02,#40,#02,#3b,#02
	db #37,#02,#40,#02,#37,#04,#30,#02
	db #44,#02,#44,#02,#42,#02,#42,#02
	db #40,#02,#40,#02,#3b,#02,#3b,#02
	db #39,#02,#40,#02,#3b,#02,#37,#02
	db #40,#02,#37,#04,#30,#02,#44,#02
	db #44,#02,#42,#02,#42,#02,#40,#02
	db #40,#02,#3b,#02,#3b,#02,#39,#02
	db #40,#02,#3b,#02,#37,#02,#40,#02
	db #37,#04,#30,#02,#44,#02,#44,#02
	db #42,#02,#42,#02,#40,#02,#40,#02
	db #3b,#02,#3b,#02,#39,#02,#40,#02
	db #3b,#02,#37,#02,#40,#02,#37,#04
	db #30,#06,#49,#02,#49,#04,#4b,#02
	db #47,#02,#4b,#04,#50,#04,#52,#02
	db #54,#02,#52,#04,#50,#06,#57,#02
	db #55,#04,#54,#04,#55,#10,#54,#02
	db #44,#02,#44,#02,#42,#02,#42,#02
	db #40,#02,#40,#02,#3b,#02,#3b,#02
	db #39,#02,#40,#02,#3b,#02,#37,#02
	db #40,#02,#37,#04,#30,#02,#44,#02
	db #44,#02,#42,#02,#42,#02,#40,#02
	db #40,#02,#3b,#02,#3b,#02,#39,#02
	db #40,#02,#3b,#02,#37,#02,#40,#02
	db #37,#04,#30,#02,#44,#02,#44,#02
	db #42,#02,#42,#02,#40,#02,#40,#02
	db #3b,#02,#3b,#02,#39,#02,#40,#02
	db #3b,#02,#37,#02,#40,#02,#37,#04
	db #30,#02,#44,#02,#44,#02,#42,#02
	db #42,#02,#40,#02,#40,#02,#3b,#02
	db #3b,#02,#39,#02,#40,#02,#3b,#02
	db #37,#02,#40,#02,#37,#04,#30,#06
	db #49,#02,#49,#04,#4b,#02,#47,#02
	db #4b,#04,#50,#04,#52,#02,#54,#02
	db #52,#04,#50,#06,#57,#02,#55,#04
	db #54,#04,#55,#10,#54,#02,#44,#02
	db #44,#02,#42,#02,#42,#02,#40,#02
	db #40,#02,#3b,#02,#3b,#02,#39,#02
	db #40,#02,#3b,#02,#37,#02,#40,#02
	db #37,#04,#30,#02,#44,#02,#44,#02
	db #42,#02,#42,#02,#40,#02,#40,#02
	db #3b,#02,#3b,#01,#47,#02,#47,#02
	db #49,#01,#47,#02,#49,#04,#50,#04
	db #40,#90
.l4fb6
	db #00,#00,#02,#44,#02,#44,#02,#42
	db #02,#42,#02,#40,#02,#40,#02,#3b
	db #02,#3b,#02,#39,#02,#40,#02,#3b
	db #02,#37,#02,#40,#02,#37,#04,#30
	db #81,#00,#01,#47,#01,#49,#01,#47
	db #01,#49,#02,#47,#01,#47,#01,#49
	db #02,#47,#04,#44,#01,#44,#02,#45
	db #02,#45,#02,#44,#01,#42,#09,#44
	db #81,#00,#01,#47,#01,#49,#01,#47
	db #01,#49,#02,#47,#01,#47,#01,#49
	db #02,#47,#04,#44,#01,#44,#02,#45
	db #02,#45,#02,#44,#01,#42,#09,#44
	db #81,#00,#01,#50,#01,#49,#01,#47
	db #01,#49,#03,#47,#01,#54,#02,#52
	db #02,#50,#03,#4b,#82,#00,#02,#42
	db #01,#44,#02,#47,#09,#44,#01,#40
	db #01,#44,#01,#47,#01,#44,#01,#47
	db #03,#50,#01,#54,#02,#52,#05,#50
	db #01,#47,#02,#47,#02,#49,#01,#47
	db #02,#49,#04,#50,#04,#40,#01,#45
	db #02,#45,#03,#45,#82,#00,#01,#47
	db #02,#47,#03,#47,#82,#00,#02,#44
	db #02,#44,#01,#47,#01,#44,#01,#47
	db #03,#50,#86,#00,#01,#40,#02,#40
	db #03,#40,#81,#00,#01,#40,#04,#44
	db #04,#42,#0c,#40,#84,#00,#01,#45
	db #02,#45,#03,#45,#82,#00,#01,#47
	db #02,#47,#03,#47,#82,#00,#02,#44
	db #02,#44,#01,#47,#01,#44,#01,#47
	db #03,#50,#86,#00,#01,#40,#02,#40
	db #03,#40,#81,#00,#01,#40,#04,#44
	db #04,#42,#0c,#40,#84,#00,#a0,#00
	db #01,#40,#01,#44,#01,#47,#01,#44
	db #01,#47,#03,#50,#01,#54,#02,#52
	db #05,#50,#01,#47,#02,#47,#02,#49
	db #01,#47,#02,#49,#04,#50,#04,#40
	db #02,#39,#02,#35,#02,#37,#82,#00
	db #02,#35,#02,#32,#02,#34,#82,#00
	db #02,#39,#02,#35,#02,#44,#02,#42
	db #02,#40,#02,#3b,#02,#39,#02,#37
	db #81,#00,#01,#47,#01,#49,#01,#47
	db #01,#49,#02,#47,#01,#47,#01,#49
	db #02,#47,#04,#44,#01,#44,#02,#45
	db #02,#45,#02,#44,#01,#42,#09,#44
	db #81,#00,#01,#47,#01,#49,#01,#47
	db #01,#49,#02,#47,#01,#47,#01,#49
	db #02,#47,#04,#44,#01,#44,#02,#45
	db #02,#45,#02,#44,#01,#42,#09,#44
	db #81,#00,#01,#50,#01,#49,#01,#47
	db #01,#49,#03,#47,#01,#54,#02,#52
	db #02,#50,#03,#4b,#82,#00,#02,#42
	db #01,#44,#02,#47,#09,#44,#01,#40
	db #01,#44,#01,#47,#01,#44,#01,#47
	db #03,#50,#01,#54,#02,#52,#05,#50
	db #01,#47,#02,#47,#02,#49,#01,#47
	db #02,#49,#04,#50,#04,#40,#01,#45
	db #02,#44,#03,#40,#82,#00,#01,#45
	db #02,#44,#03,#40,#84,#00,#02,#45
	db #02,#44,#02,#40,#01,#45,#02,#44
	db #03,#40,#02,#40,#02,#49,#02,#49
	db #02,#47,#02,#47,#06,#44,#02,#45
	db #0c,#40,#85,#00,#01,#47,#01,#49
	db #01,#47,#01,#49,#02,#47,#01,#47
	db #01,#49,#02,#47,#04,#44,#01,#44
	db #02,#45,#02,#45,#02,#44,#01,#42
	db #09,#44,#81,#00,#01,#47,#01,#49
	db #01,#47,#01,#49,#02,#47,#01,#47
	db #01,#49,#02,#47,#04,#44,#01,#44
	db #02,#45,#02,#45,#02,#44,#01,#42
	db #09,#44,#81,#00,#01,#50,#01,#49
	db #01,#47,#01,#49,#03,#47,#01,#54
	db #02,#52,#02,#50,#03,#4b,#82,#00
	db #02,#42,#01,#44,#02,#47,#09,#44
	db #01,#40,#01,#44,#01,#47,#01,#44
	db #01,#47,#03,#50,#01,#54,#02,#52
	db #05,#50,#01,#47,#02,#47,#02,#49
	db #01,#47,#02,#49,#04,#50,#04,#40
	db #01,#45,#02,#45,#03,#45,#82,#00
	db #01,#47,#02,#47,#03,#47,#82,#00
	db #02,#44,#02,#44,#01,#47,#01,#44
	db #01,#47,#03,#50,#86,#00,#01,#40
	db #02,#40,#03,#40,#81,#00,#01,#40
	db #04,#44,#04,#42,#0c,#40,#84,#00
	db #02,#44,#02,#44,#02,#42,#02,#42
	db #02,#40,#02,#40,#02,#3b,#02,#3b
	db #02,#39,#02,#40,#02,#3b,#02,#37
	db #02,#40,#02,#37,#04,#30,#01,#40
	db #01,#44,#01,#47,#01,#44,#01,#47
	db #03,#50,#01,#54,#02,#52,#05,#50
	db #01,#47,#02,#47,#02,#49,#01,#47
	db #02,#49,#04,#50,#04,#40,#90,#00
	db #00
;
.init_music
;
	ld bc,l4ae8
	ld de,l4d13
	ld hl,l4fb6
	jp l0902
;
.game_name
	db "Tom & Jerry",0
.game_year
	db "1989",0
.game_publisher
	db "Magic Bytes",0
.music_author
	db "",0
.music_comment
	db "",0

	read "music_end_v1_0.asm"
